<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RoleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $role = optional($this->route('role'));

        return [
            'display_name' => 'bail|required|max:50|unique:roles,display_name,'.(int) $role->id,
            'name'         => 'bail|required|max:50|unique:roles,name,'.(int) $role->id,
        ];
    }

    public function attributes()
    {
        return [
            'display_name' => '角色名',
            'name'         => '标志',
        ];
    }
}
